import http from "../../http"
import type { LoginReq, UserPageQuery, UserReq } from "./UserModel"

export class SysUserApi {
    static newAdd(userReq: UserReq) {
        return http.post('/user', userReq)
    }

    static edit(saveReq: UserReq) {
        return http.put('/user', saveReq)
    }

    static page(query: UserPageQuery) {
        return http.get('/user/page', query)
    }

    static delete(userId: number | string) {
        return http.delete(`/user/${userId}`)
    }

    /**
     * 根据用户ID查询用户的角色ID列表
     */
    static roleIds(userId: string | number) {
        return http.get('/user/role-ids', { userId })
    }

    static resetPassword(userId: number | string) {
        return http.post('/user/reset-password', { userId })
    }

    static captcha() {
        return http.get('/user/captcha')
    }

    static login(req: LoginReq) {
        return http.post('/user/login', req)
    }

    static updatePassword(req: any) {
        return http.post('/user/update-password', req)
    }

    static getUserInfo(userId: string | number) {
        return http.get('/user/get-user-info', { userId })
    }
}